package com.bibrApp.difu.fragment.jiedai_mvp;

import android.graphics.Color;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bibrApp.difu.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

public class TabAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    int selected = 0;

    public TabAdapter() {
        super(R.layout.item_c2c_tab, new ArrayList<>());
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, String item) {

        helper.setText(R.id.item_text, item);
        if (getData().indexOf(item) == selected) {
            helper.setBackgroundRes(R.id.item_text, R.drawable.bg_jiedai_tab_saixuan);
            helper.setTextColor(R.id.item_text, Color.parseColor("#1D89E4"));
        } else {
            helper.setBackgroundRes(R.id.item_text, R.drawable.bg_border_gray4);
            helper.setTextColor(R.id.item_text, Color.parseColor("#999999"));
        }
    }

    public void setSelected(int selected) {
        this.selected = selected;
        notifyDataSetChanged();
    }

    public int getSelected() {
        return selected;
    }

    public void setDatas(List<String> datas, int selected) {
        this.selected = selected;
        setNewData(datas);
    }
}
